<template>
  <div class="app-container">
    <el-row :gutter="20">
      <el-col :span="show ? rowObj.T1 : rowObj.F1" :xs="show ? rowObj.T2 : rowObj.F2">
        <workSiteLeft ref="workSiteLeft" :show="show" @showLeft="showLeft" @queryVal="queryVal" />
      </el-col>

      <el-col :span="show ? rowObj.T3 : rowObj.F3" :xs="show ? rowObj.T4 : rowObj.F4">
        <div class="container-body">
          <el-form :inline="true" :model="queryParams" size="mini" style=" display: flex;justify-content: space-between;">
            <div>
              <el-button style="margin-right: 6px" size="mini" :icon="show ? 'el-icon-s-fold' : 'el-icon-s-unfold'" circle @click="showLeft(show)"></el-button>
              <el-form-item label="拌合楼">
                <el-select style="width: 130px" v-model="queryParams.stationCode" clearable size="mini" placeholder="请选择拌合楼">
                  <el-option v-for="item in cementListData" :key="item.id" :label="item.name" :value="item.code"></el-option>
                </el-select>
              </el-form-item>

              <el-form-item label="用料项目">
                <el-select style="width: 120px" size="mini" v-model="queryParams.projectId" placeholder="请选择" filterable clearable :popper-append-to-body="false">
                  <el-option v-for="item in projectIdList" :key="item.id" :label="item.name" :value="item.id"></el-option>
                </el-select>
              </el-form-item>

              <el-form-item label="级配类型">
                <el-select style="width: 120px" v-model="queryParams.matchType" clearable size="mini" placeholder="请选择级配类型">
                  <el-option v-for="item in matchTypeList" :key="item.id" :label="item.type" :value="item.type"></el-option>
                </el-select>
              </el-form-item>

              <el-form-item label="配方编号">
                <el-select style="width: 120px" v-model="queryParams.matchCode" clearable size="mini" placeholder="请选择">
                  <el-option v-for="item in matchCodeList" :key="item.value" :label="item.label" :value="item.value"></el-option>
                </el-select>
              </el-form-item>

              <el-form-item label="生产类型">
                <el-select style="width: 120px" size="mini" v-model="queryParams.produceType" placeholder="请选择" clearable :popper-append-to-body="false">
                  <el-option v-for="item in produceTypeOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
                </el-select>
              </el-form-item>

              <el-form-item>
                <!-- v-if="$hasPermission('api:asphaltMatch:list')" -->
                <el-button icon="el-icon-search" type="primary" @click="handleQuery()">查询</el-button>
              </el-form-item>
            </div>

            <el-form-item><el-button type="success" icon="el-icon-plus" @click="showEdit()">添加</el-button></el-form-item>
          </el-form>

          <el-table :data="dataList" v-loading="loading" fit border size="mini" highlight-current-row stripe>
            <el-table-column prop="projectName" label="用料项目" align="center" min-width="200px" show-overflow-tooltip ></el-table-column>
            <el-table-column prop="stationName" label="拌合楼" align="center" min-width="120px" show-overflow-tooltip ></el-table-column>
            <el-table-column prop="matchType" label="级配类型" align="center" min-width="90px" show-overflow-tooltip></el-table-column>
            <el-table-column prop="matchName" label="配方名称" align="center" min-width="90px" show-overflow-tooltip></el-table-column>
            <el-table-column prop="matchCode" label="配方编号" align="center" min-width="130px" show-overflow-tooltip></el-table-column>
            <el-table-column prop="temperature" label="设计温度" align="center" min-width="73px" show-overflow-tooltip>
              <template slot-scope="scope">{{ scope.row | showTemperature }}</template>
            </el-table-column>
            <el-table-column prop="asphaltAggregateRatio" label="油石比" align="center" min-width="80px" show-overflow-tooltip></el-table-column>
            <el-table-column prop="gravel1" label="骨料1" align="center" min-width="80px" show-overflow-tooltip>
              <template slot-scope="scope">{{ scope | showGravelAndPowder }}</template>
            </el-table-column>
            <el-table-column prop="gravel2" label="骨料2" align="center" min-width="80px" show-overflow-tooltip>
              <template slot-scope="scope">{{ scope | showGravelAndPowder }}</template>
            </el-table-column>
            <el-table-column prop="gravel3" label="骨料3" align="center" min-width="80px" show-overflow-tooltip>
              <template slot-scope="scope">{{ scope | showGravelAndPowder }}</template>
            </el-table-column>
            <el-table-column prop="gravel4" label="骨料4" align="center" min-width="80px" show-overflow-tooltip>
              <template slot-scope="scope">{{ scope | showGravelAndPowder }}</template>
            </el-table-column>
            <el-table-column prop="gravel5" label="骨料5" align="center" min-width="80px" show-overflow-tooltip>
              <template slot-scope="scope">{{ scope | showGravelAndPowder }}</template>
            </el-table-column>
            <el-table-column prop="gravel6" label="骨料6" align="center" min-width="80px" show-overflow-tooltip>
              <template slot-scope="scope">{{ scope | showGravelAndPowder }}</template>
            </el-table-column>
            <el-table-column prop="powder1" label="粉料1" align="center" min-width="80px" show-overflow-tooltip>
              <template slot-scope="scope">{{ scope | showGravelAndPowder }}</template>
            </el-table-column>
            <el-table-column prop="powder2" label="粉料2" align="center" min-width="80px" show-overflow-tooltip>
              <template slot-scope="scope">{{ scope | showGravelAndPowder }}</template>
            </el-table-column>
            <el-table-column prop="powder3" label="粉料3" align="center" min-width="80px" show-overflow-tooltip>
              <template slot-scope="scope">{{ scope | showGravelAndPowder }}</template>
            </el-table-column>
            <el-table-column prop="recycledMaterial" label="再生料" align="center" min-width="80px" show-overflow-tooltip>
              <template slot-scope="scope">{{ scope.row.recycledMaterial | showNumber }}</template>
            </el-table-column>
            <el-table-column prop="updateName" label="修改人" align="center" width="80px" show-overflow-tooltip></el-table-column>
            <el-table-column prop="updateDate" label="修改时间" align="center" width="133px" show-overflow-tooltip></el-table-column>
            <el-table-column label="操作" align="center" width="95px" fixed="right">
              <template slot-scope="scope">
                <!-- v-if="$hasPermission('api:asphaltMatch:edit')" -->
                <el-link type="primary" @click="showEdit(scope.row.id)">编辑</el-link>
                <el-divider direction="vertical"></el-divider>
                <!-- v-if="$hasPermission('api:asphaltMatch:remove')" -->
                <el-link type="primary" @click="onDelete(scope.row.id)">删除</el-link>
              </template>
            </el-table-column>
          </el-table>
          <pagination class="fenye" v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
        </div>
      </el-col>
    </el-row>

    <el-dialog :title="isAdd ? '添加设计生产配比' : '修改设计生产配比'" :visible.sync="visible" :close-on-click-modal="false" :close-on-press-escape="false" :before-close="doClose" width="1000px">
      <div>
        <el-form ref="editForm" lass="myForm" size="mini" :model="form" :rules="rules" label-width="130px" class="myForm" v-loading="loadingForm">
          <el-row :gutter="0">
            <el-col :span="12">
              <el-form-item label="所属项目" prop="projectId">
                <el-select size="mini" v-model="form.projectId" :disabled="!isAdd" placeholder="请选择" filterable clearable :popper-append-to-body="false">
                  <el-option v-for="item in projectIdList" :key="item.id" :label="item.name" :value="item.id"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="拌合楼" prop="stationCode">
                <el-select v-model="form.stationCode" clearable size="mini" :disabled="!isAdd" placeholder="请选择拌合楼">
                  <el-option v-for="item in cementListData" :key="item.id" :label="item.name" :value="item.code"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="配方名称" prop="matchName">
                <el-select size="mini" v-model="form.matchName" :disabled="!isAdd" placeholder="请选择" filterable clearable :popper-append-to-body="false">
                  <el-option v-for="item in matchNameList" :key="item.id" :label="item.name" :value="item.name"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="配方编号" prop="matchCode">
                <el-input placeholder="配方编号" size="mini" v-model="form.matchCode" :disabled="!isAdd" maxlength="20"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="摊铺层级" prop="pavingLevel">
                <el-select v-model="form.pavingLevel" placeholder="摊铺层级" clearable :popper-append-to-body="false">
                  <el-option v-for="item of cementPavingLevelList" :key="item.code" :label="item.shortname" :value="item.code"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="生产类型" prop="productionType">
                <el-select size="mini" v-model="form.productionType" placeholder="请选择" clearable style="width: 100%" :popper-append-to-body="false">
                  <el-option v-for="item in produceTypeOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="温度下限" prop="temperatureMin">
                <el-input-number size="mini" placeholder="温度下限" v-model="form.temperatureMin" :controls="false" :min="0" :precision="2"></el-input-number>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="温度上限" prop="temperatureMax">
                <el-input-number size="mini" placeholder="温度上限" v-model="form.temperatureMax" :controls="false" :min="0" :precision="2"></el-input-number>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="油石比基准值" prop="asphaltAggregateRatio">
                <el-input-number size="mini" placeholder="油石比基准值" v-model="form.asphaltAggregateRatio" :controls="false" :min="0" :precision="2"></el-input-number>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="油石比允许偏差" prop="asphaltAggregateError">
                <el-col :span="2" class="colSplit">±</el-col>
                <el-col :span="22">
                  <el-input-number size="mini" placeholder="油石比允许偏差" v-model="form.asphaltAggregateError" :controls="false" :min="0" :precision="2"></el-input-number>
                </el-col>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="骨料1" class="form-item-out">
                <el-col :span="10">
                  <el-form-item label-width="0px" prop="gravel1Name">
                    <el-input size="mini" placeholder="骨料1名称" maxlength="20" v-model="form.gravel1Name"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="2">&nbsp;</el-col>
                <el-col :span="10">
                  <el-form-item label-width="0px" prop="gravel1">
                    <el-input-number size="mini" placeholder="骨料1占比" v-model="form.gravel1" :controls="false" :max="100" :min="0" :precision="2"></el-input-number>
                  </el-form-item>
                </el-col>
                <el-col :span="2" class="colSplit">%</el-col>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="骨料2" class="form-item-out">
                <el-col :span="10">
                  <el-form-item label-width="0px" prop="gravel2Name">
                    <el-input size="mini" placeholder="骨料2名称" maxlength="20" v-model="form.gravel2Name"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="2">&nbsp;</el-col>
                <el-col :span="10">
                  <el-form-item label-width="0px" prop="gravel2">
                    <el-input-number size="mini" placeholder="骨料2占比" :max="100" v-model="form.gravel2" :controls="false" :min="0" :precision="2"></el-input-number>
                  </el-form-item>
                </el-col>
                <el-col :span="2" class="colSplit">%</el-col>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="骨料3" class="form-item-out">
                <el-col :span="10">
                  <el-form-item label-width="0px" prop="gravel3Name">
                    <el-input size="mini" placeholder="骨料3名称" maxlength="20" v-model="form.gravel3Name"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="2">&nbsp;</el-col>
                <el-col :span="10">
                  <el-form-item label-width="0px" prop="gravel3">
                    <el-input-number size="mini" placeholder="骨料3占比" v-model="form.gravel3" :max="100" :controls="false" :min="0" :precision="2"></el-input-number>
                  </el-form-item>
                </el-col>
                <el-col :span="2" class="colSplit">%</el-col>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="骨料4" class="form-item-out">
                <el-col :span="10">
                  <el-form-item label-width="0px" prop="gravel4Name">
                    <el-input size="mini" placeholder="骨料4名称" maxlength="20" v-model="form.gravel4Name"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="2">&nbsp;</el-col>
                <el-col :span="10">
                  <el-form-item label-width="0px" prop="gravel4">
                    <el-input-number size="mini" placeholder="骨料4占比" :max="100" v-model="form.gravel4" :controls="false" :min="0" :precision="2"></el-input-number>
                  </el-form-item>
                </el-col>
                <el-col :span="2" class="colSplit">%</el-col>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="骨料5" class="form-item-out">
                <el-col :span="10">
                  <el-form-item label-width="0px" prop="gravel5Name">
                    <el-input size="mini" placeholder="骨料5名称" maxlength="20" v-model="form.gravel5Name"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="2">&nbsp;</el-col>
                <el-col :span="10">
                  <el-form-item label-width="0px" prop="gravel5">
                    <el-input-number size="mini" placeholder="骨料5占比" :max="100" v-model="form.gravel5" :controls="false" :min="0" :precision="2"></el-input-number>
                  </el-form-item>
                </el-col>
                <el-col :span="2" class="colSplit">%</el-col>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="骨料6" class="form-item-out">
                <el-col :span="10">
                  <el-form-item label-width="0px" prop="gravel6Name">
                    <el-input size="mini" placeholder="骨料6名称" maxlength="20" v-model="form.gravel6Name"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="2">&nbsp;</el-col>
                <el-col :span="10">
                  <el-form-item label-width="0px" prop="gravel6">
                    <el-input-number size="mini" placeholder="骨料6占比" :max="100" v-model="form.gravel6" :controls="false" :min="0" :precision="2"></el-input-number>
                  </el-form-item>
                </el-col>
                <el-col :span="2" class="colSplit">%</el-col>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="粉料1" class="form-item-out">
                <el-col :span="10">
                  <el-form-item label-width="0px" prop="powder1Name">
                    <el-input size="mini" placeholder="粉料1名称" maxlength="20" v-model="form.powder1Name"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="2">&nbsp;</el-col>
                <el-col :span="10">
                  <el-form-item label-width="0px" prop="powder1">
                    <el-input-number size="mini" placeholder="粉料1占比" :max="100" v-model="form.powder1" :controls="false" :min="0" :precision="2"></el-input-number>
                  </el-form-item>
                </el-col>
                <el-col :span="2" class="colSplit">%</el-col>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="粉料2" class="form-item-out">
                <el-col :span="10">
                  <el-form-item label-width="0px" prop="powder2Name">
                    <el-input size="mini" placeholder="粉料2名称" maxlength="20" v-model="form.powder2Name"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="2">&nbsp;</el-col>
                <el-col :span="10">
                  <el-form-item label-width="0px" prop="powder2">
                    <el-input-number size="mini" placeholder="粉料2占比" :max="100" v-model="form.powder2" :controls="false" :min="0" :precision="2"></el-input-number>
                  </el-form-item>
                </el-col>
                <el-col :span="2" class="colSplit">%</el-col>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="粉料3" class="form-item-out">
                <el-col :span="10">
                  <el-form-item label-width="0px" prop="powder3Name">
                    <el-input size="mini" placeholder="粉料3名称" maxlength="20" v-model="form.powder3Name"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="2">&nbsp;</el-col>
                <el-col :span="10">
                  <el-form-item label-width="0px" prop="powder3">
                    <el-input-number size="mini" placeholder="粉料3占比" :max="100" v-model="form.powder3" :controls="false" :min="0" :precision="2"></el-input-number>
                  </el-form-item>
                </el-col>
                <el-col :span="2" class="colSplit">%</el-col>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="再生料" prop="recycledMaterial">
                <el-col :span="22">
                  <el-input-number size="mini" placeholder="再生料" :max="100" v-model="form.recycledMaterial" :controls="false" :min="0" :precision="2"></el-input-number>
                </el-col>
                <el-col :span="2" class="colSplit">%</el-col>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <span slot="footer">
        <el-button size="mini" @click="doClose">取消</el-button>
        <el-button type="primary" size="mini" @click="doSubmit" :loading="submitting">确定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { sysStationList, asphaltMatch, asphaltMatchAdd, asphaltMatchEdit, cementMatchRemove, materielProject, getInitMatchCode, asphaltMatchName, asphaltMatchLook } from "@/api/bitumenMixingStation/matchingManage/designMatching";
import { getcodelistall } from "@/api/waterStability/designMatching";
import { asphaltMatchTypeList } from "@/api/bitumenMixingStation/producedData/monitor";
import workSiteLeft from "@/views/components/workSiteLeft";


export default {
  name: "designMatching",
  components: { workSiteLeft },
  data() {
    return {
      show: true,
      rowObj: {
        T1: 3,
        T2: 24,
        T3: 21,
        T4: 24,
        F1: 0,
        F2: 0,
        F3: 24,
        F4: 24,
      },
      submitting: true,
      visible: false,
      isAdd: true,
      dataList: [],
      loading: false,//表格加载
      loadingForm: false,//新增修改加载
      cementListData: [],//拌合楼下拉列表
      matchTypeList: [],//级配类型
      matchCodeList: [],
      projectIdList: [],
      matchNameList: [],
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      total: 0,
      produceTypeOptions: [
        {
          value: '1',
          label: '进料加工'
        },
        {
          value: '0',
          label: '来料加工'
        }
      ],
      form: {},
      rules: {
        projectId: [{ required: true, message: '请选择所属项目', trigger: 'change' }],
        productionType: [{ required: true, message: '请选择生产类型', trigger: 'change' }],
        matchName: [{ required: true, message: '请选择配方名称', trigger: 'blur' }],
        matchCode: [{ required: true, message: '请输入配方编号', trigger: 'blur' }],
        asphaltAggregateRatio: [{ required: true, message: '请输入油石比基准值', trigger: 'blur' }],
        asphaltAggregateError: [{ required: true, message: '请输入油石比允许偏差', trigger: 'blur' }]
        /*pavingLevel: [{ required: true, message: '请选择摊铺层级', trigger: 'change' }],*/
        /*temperature: [{ required: true, message: '请输入设计温度', trigger: 'blur' }],*/
        /*temperatureMax: [{ required: true, message: '请输入温度上限', trigger: 'blur' }],
        temperatureMin: [{ required: true, message: '请输入温度下限', trigger: 'blur' }],*/
        // stationCode: [{ required: true, message: '请选择拌合楼', trigger: 'change' }],
        /*gravel1Name: [{ required: true, message: '请输入骨料名称', trigger: 'blur' }],
        gravel1: [{ required: true, message: '请输入骨料占比', trigger: 'blur' }],
        gravel2Name: [{ required: true, message: '请输入骨料名称', trigger: 'blur' }],
        gravel2: [{ required: true, message: '请输入骨料占比', trigger: 'blur' }],
        gravel3Name: [{ required: true, message: '请输入骨料名称', trigger: 'blur' }],
        gravel3: [{ required: true, message: '请输入骨料占比', trigger: 'blur' }],
        gravel4Name: [{ required: true, message: '请输入骨料名称', trigger: 'blur' }],
        gravel4: [{ required: true, message: '请输入骨料占比', trigger: 'blur' }],
        gravel5Name: [{ required: true, message: '请输入骨料名称', trigger: 'blur' }],
        gravel5: [{ required: true, message: '请输入骨料占比', trigger: 'blur' }],
        gravel6Name: [{ required: true, message: '请输入骨料名称', trigger: 'blur' }],
        gravel6: [{ required: true, message: '请输入骨料占比', trigger: 'blur' }],
        powder1Name: [{ required: true, message: '请输入粉料1名称', trigger: 'blur' }],
        powder1: [{ required: true, message: '请输入粉料1占比', trigger: 'blur' }],
        powder2Name: [{ required: true, message: '请输入粉料2名称', trigger: 'blur' }],
        powder2: [{ required: true, message: '请输入粉料2占比', trigger: 'blur' }],
        powder3Name: [{ required: true, message: '请输入粉料3名称', trigger: 'blur' }],
        powder3: [{ required: true, message: '请输入粉料3占比', trigger: 'blur' }],
        recycledMaterial: [{ required: true, message: '请输入再生料占比', trigger: 'blur' }]*/
      },
      cementPavingLevelList: []
    };
  },
  filters: {
    /* 显示骨料或粉料信息 */
    showGravelAndPowder(val) {
      let property = val.column.property;
      let data = val.row;
      let value = data[property];
      if (!!value) {
        let name = !!data[property + 'Name'] ? data[property + 'Name'] + '：' : '';
        return name + value;
      }
      return '/';
    },

    /* 显示数字 */
    showNumber(val) {
      if (!!val) {
        return val;
      }
      return '/';
    },
    /* 显示温度范围 */
    showTemperature(val) {
      let min = !!val.temperatureMin ? val.temperatureMin : '/';
      let max = !!val.temperatureMax ? val.temperatureMax : '/';
      if (min == max) {
        return min;
      }
      return min + '~' + max;
    }
  },
  created() {
    this.getCementList();
    this.getAsphaltMatchTypeList()
    this.getInitMatchCodeData()
    this.getMaterielProject()
    this.getCementGravelList()
    this.getAsphaltMatchName()
    this.getList();
  },
  methods: {
    showLeft(show) {
      this.show = !show;
    },
    queryVal(val) {
      this.queryParams.id = val.id;
      this.handleQuery();
    },
    getList() {
      this.loading = true;
      asphaltMatch(this.queryParams).then((res) => {
        this.dataList = res.rows;
        this.total = res.total;
        this.loading = false;
      });
    },
    getSearchParams() {
      const params = {};
      for (const key in this.queryParams) {
        if (key === "time") {
          const time = this.queryParams[key];
          if (time && time.length === 2) {
            params.startTime = time[0];
            params.endTime = time[1];
          }
        } else {
          params[key] = this.queryParams[key];
        }
      }
      return params;
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams = this.getSearchParams();
      this.queryParams.pageNum = 1;
      this.getList();
    },
    // 用料项目
    getMaterielProject() {
      materielProject().then((res) => {
        this.projectIdList = res.rows
      })
    },
    // 配方编号
    getInitMatchCodeData() {
      getInitMatchCode().then((res) => {
        this.matchCodeList = res.data
      })
    },
    // 查询拌合楼下拉列表
    getCementList() {
      sysStationList({
        type: 'asphalt'
      }).then((res) => {
        this.cementListData = res.data || [];
      });
    },
    // 级配类型
    getAsphaltMatchTypeList() {
      asphaltMatchTypeList().then((res) => {
        this.matchTypeList = res.data;
      });
    },
    getAsphaltMatchName() {
      asphaltMatchName().then((res) => {
        this.matchNameList = res.data
      })
    },
    /* 获取摊铺层级 */
    getCementGravelList() {
      getcodelistall({
        codeid: "paving_level",
      }).then((res) => {
        this.cementPavingLevelList = res.data || [];
      });
    },
    // 删除
    onDelete(id) {
      this.$confirm("此操作将删除该条数据, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
      .then(() => {
        cementMatchRemove(id).then((res) => {
          this.getList();
          this.$message({
            type: "success",
            message: "删除成功!",
          });
        });
      })
      .catch(() => {
        this.$message({
          type: "info",
          message: "已取消删除",
        });
      });
    },
    /* 关闭弹窗 */
    doClose() {
      this.visible = false;
    },
    /* 提交表单 */
    doSubmit() {
      this.$refs.editForm.validate((valid) => {
        if (valid) {
          if (this.isAdd) {
            // 新增
            // this.form.stationCode = "111";
            asphaltMatchAdd(this.form).then((res) => {
              this.$message.success("新增设计生产配比成功！");
              this.getList();
              this.visible = false;
              // this.btnLoading = false;
              // this.open = false;
            })
          } else {
            // 修改
            asphaltMatchEdit(this.form).then((res) => {
              this.$message.success("修改设计生产配比成功！");
              this.getList();
              this.visible = false;
              // this.open = false;
            })
          }
        }
      });
    },
    showEdit(id) {
      this.visible = true;
      this.isAdd = null == id || undefined == id;
      this.loading = false;
      this.submitting = false;
      this.$nextTick(() => {
        if (this.isAdd) {
          this.form = {}
          this.$refs['editForm'].resetFields();
        } else {
          this.infoForm(id);
        }
      });
    },
    /* 获取数据 @param {*} id 数据主键 */
    infoForm(id) {
      this.loading = true;
      this.$refs['editForm'].clearValidate();
      asphaltMatchLook(id).then((res) => {
        this.form = res.data;
        this.loading = false;
      }).catch(() => {
        this.form = {}
        this.loading = false;
      });
    },
  },
};
</script>

<style scoped>
.myForm>>>.el-input-number {
  width: 100%;
}
.myForm>>>.el-input__inner {
  text-align: left;
}
.myForm>>>.el-input-number {
  width: 100%;
}
.myForm>>>.el-input__inner {
  text-align: left;
}
.form-item-out {
  margin-bottom: 0px;
}
.colSplit {
  text-align: center;
  font-size: 16px;
}
.el-col {
  border: 1px solid transparent;
}
</style>

<style scoped lang="scss"></style>
